package com.ghsc.ghxc.jsb.ui.message.view.gif

import androidx.lifecycle.MutableLiveData
import com.cn.appcore.base.BaseViewModel
import com.cn.appcore.ext.executeResponse
import com.cn.appcore.http.bean.BaseResponse
import com.ghsc.ghxc.jsb.api.ApiMarket
import com.ghsc.ghxc.jsb.ui.live.bean.GifResult
import com.ghsc.ghxc.jsb.ui.message.bean.ImSendGifResult
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

/**
 * 项目：GuoHuaMall
 * 包名：com.ghsc.ghxc.ui.live.view.gif
 * 类名：GiftViewModel
 * 创建时间：2023/9/14 22:37
 * 创建人 @author： xiaolin
 * 描述 ：Todo...
 */
class ImGiftViewModel :BaseViewModel() {



    /** 礼物列表 **/
    var onGetGifListData = MutableLiveData<BaseResponse<GifResult>>()
    fun onGetGifListMethod(paras:String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onGetMsgGifListData(paras) }
            executeResponse(
                response,
                { onGetGifListData.value = response},
                { againLoginMsg.value = response.msg}
            ) { errorMsg.value = response.msg }

        }
    }
    /** 送礼物 **/
    var onToGifData = MutableLiveData<BaseResponse<ImSendGifResult>>()
    fun onToGifMethod(paras:String) {
        launch {
            val response = withContext(Dispatchers.IO) { ApiMarket.service.onToMsgGifData(paras) }
            executeResponse(
                response,
                { onToGifData.value = response},
                { againLoginMsg.value = response.msg}
            ) { errorMsg.value = response.msg }

        }
    }



}